06. Intro: Modeling Relationships
REVIEW CRUD on an item Heading
Introduction: Modeling Relationships
So far, we've completed doing CRUD for a single model: a To Do item. The CRUD implementation patterns we've learned can apply to multiple models for any given web application, so long as those models do not have relationships between them. However, we'll often be implementing web apps with multiple models that have relationships with one another.
The relationships between these models can determine if certain actions on one model should happen on other models, so that when something happens to one model, related model objects should also be affected (by being created, read, updated, or deleted).
Examples are:
- Removing a User's account should remove all of that user's photos, documents, etc.
- Deleting a Discussion Thread should delete all of its comments.
- Deactivating the profile of an Airbnb host should deactivate all of that host's listings.
- Accessing a Blog Post should also access all of its comments.
- Accessing an Airbnb host's profile should also access all of their listings.
In order to handle CRUD across related models that can often have relationships with one another, we'll need to learn about how we model relationships, both reviewing relationship modeling in SQL and learning particularly about how we implement them in SQLAlchemy ORM.
Let's put aside our To-Do app development for now to learn about mapping relationships between models. Once we've done that, we'll come back to our To-Do app to implement them.
ND004 C01 L07 06 REVIEW CRUD On An Item